﻿
--#include "data\config\misc\RobotCfg.lua" once

function autoRobot(MaxLevel, PlayerCount, OpenServerDay)
	MaxLevel = tonumber(MaxLevel)
	PlayerCount = tonumber(PlayerCount)
	OpenServerDay = tonumber(OpenServerDay)
	--print(string.format("robot paras:%d, %d, %d", MaxLevel, PlayerCount, OpenServerDay))
	local config = RobotConfig
	local index = 0
	for k, v in ipairs(config.robotRule) do
		if PlayerCount >= v.onLine[1] and PlayerCount <= v.onLine[2] 
			and OpenServerDay >= v.openDay[1] and OpenServerDay <= v.openDay[2] 
			and MaxLevel >= v.maxLevel[1] and MaxLevel <= v.maxLevel[2] then
			index = k
			break
		end
	end

	--print(string.format("robot rule select:%d", index))
	if index == 0 then
		return
	end

	local rule = config.robotRule[index]
	for k, v in ipairs(rule.numList) do
		if config.robotHook[k] then
			local monsterList = config.robotHook[k].monster
			local sceneList = config.robotHook[k].scene
			local monsterId = 0
			local scene = {1, 2, 3, 4, 5}
			local hScene = nil
			for i = 1, v do 
				monsterId = monsterList[math.random(#monsterList)]
				scene = sceneList[math.random(#sceneList)]
				hScene = Fuben.getSceneHandleById(scene[1], 0)
				Fuben.createMonstersInRange(hScene, monsterId, scene[2], scene[3], scene[4], scene[5], 1, 160 + math.random(30))
			end
		end
	end
end


